<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>报告管理</title>
<link href="/stylesheets/survey_public.css" rel="stylesheet" type="text/css" />
<style>
#header{ width:885px; float:left; height:120px; background:url(/images/user/report_list/header.jpg) no-repeat;}
#header ol li{ width:690px; height:92px; margin-top:25px; float:left;}

#header ul{ width:170px; height:84px; float:left; margin-top:10px;}
#header ul li{line-height:38px; font-size:14px; color:#FFFFFF; text-align:right;}
#header ul li a{ color:#FFFFFF; font-size:12px; padding-right:20px;}

#content{ width:885px; float:left;}
.content01{ width:885px; float:left; height:42px; border-bottom:1px solid #1a80d0;}
#guan{ width:190px; height:42px; line-height:42px; padding-left:112px; float:left;}
#guan li{ width:50px; float:left;}
#guan2{ width:190px; height:42px; line-height:42px; float:left;}
#guan2 li{ width:60px; float:left;}
#text{ width:114px; height:20px; border:1px solid #a5acb2; margin-top:10px;}
#guan3{ width:92px; float:right; padding-right:96px;}
#guan3 li{ width:92px; height:34px; padding:9px 0 0 0px; float:left;}

.content02{ width:870px; line-height:45px; float:left; padding-left:25px;}

.content03{ width:819px; float:left; padding:5px 0 0 68px;}
.STYLE1 {color: #FFFFFF}
.back{ width:102px; height:35px; float:right; padding-right:20px; margin-top:10px;}

.left{ width:170px; height:420px; float:left; background:url(/images/user/report_list/leftbg.jpg) no-repeat;margin-top:5px;}
.left01{ width:144px; height:146px; margin:10px 0 0 12px; display:inline; border-bottom:1px dashed #0074c6; float:left;}
.left01 ul{ width:137px; height:22px; float:left; margin-bottom:11px;}
.left01 ul li{ width:63px; height:22px; float:left; line-height:26px; text-align:right; }
.left01 ul li.bc{ width:74px; height:22px; float:left; text-align:left;}
#text{ width:70px; height:22px; border:1px solid #0074c6;}
.left01 p{ width:76px; height:22px; float:left; padding:3px 0 0 34px;margin-top:12px;}

.left02{ width:144px; height:112px; margin-top:12px; float:left; margin-left:12px; display:inline; border-bottom:1px dashed #0074c6; overflow:hidden; }
.left02 ul{ width:65px; height:88px; float:left;}
.left02 ul li{ width:65px; float:left; height:22px; line-height:22px; margin-bottom:3px;}
.left02 ul li a{ color:#000000;}
.left02 ol{ width:23px; float:left; margin-left:17px; display:inline;}
.left02 ol li{ width:23px; height:22px; float:left; margin-bottom:3px;}
.left02 ol li img{ margin-top:3px;}

.left02 ul.tubiao{ width:25px; height:88px; float:left;}
.left02 ul li.tt{ width:30px; float:left; height:23px; margin-bottom:3px;}

.left03{ width:144px; height:57px; float:left; margin:10px 0 0 12px; display:inline; border-bottom:1px dashed #0074c6; overflow:hidden;}
.left03 ul{ width:65px; height:57px; float:left;}
.left03 ul li{ width:65px; float:left; height:22px; line-height:22px; margin-bottom:3px; font-weight:bold;}
.left03 ul li a{ color:#000000;}
.left03 ol{ width:23px; float:left; margin-left:17px; display:inline;}
.left03 ol li{ width:23px; height:22px; float:left; margin-bottom:3px;}
.left03 ol li img{ margin-top:3px;}

.left03 ul.tubiao2{ width:25px; height:57px; float:left;}
.left03 ul li.tt2{ width:30px; float:left; height:22px; line-height:22px; margin-bottom:3px;}

.left05{ width:144px; height:24px; float:left; padding:15px 0 0 12px;}

.left05 ul{ width:65px; height:24px; float:left;}
.left05 ul li{ width:65px;  height:24px; line-height:24px; float:left; dispaly:inline;}
.left05 ul li a{ color:#000000;}
.left05 ol{ width:23px; float:left; margin-left:17px; display:inline;}
.left05 ol li{ width:20px; height:22px; float:left; margin-bottom:3px;}
.left05 ol li img{ margin-top:3px;}

.left05 ul.tubiao3{ width:22px; height:25px; float:left;}
.left05 ul li.tt3{ width:22px; float:left; height:22px; line-height:22px; margin-top:0px;}

.right{ width:710px; float:right; margin-top:5px;}
.right ul{ width:13px; height:13px; float:left; margin-top:6px!important; margin-top:3px; margin-right:8px; display:inline;}
.right ul li{ width:13px; height:13px; float:left;}
.right ol{ width:13px; height:13px; float:left; margin-top:6px; margin-right:8px; display:inline;}
.right ol li{ width:13px; height:13px; float:left;}
.right p{ width:280px; height:23px; float:left;}
.right span.top_list{ width:115px; height:23px; float:left;margin:2px 0 0 3px;}
.right span.top_back{ width:100px; height:23px; float:right;margin:2px 14px 0 3px;}
.right em{ width:86px; height:23px; float:left;}

#footer{ width:100%; height:200px; float:left; background:url(/images/user/report_list/footer.jpg) no-repeat; text-align:center; color:#295c72;}
#footer h1{ margin-top:100px;}
</style>
<script src="/javascripts/WebCalendar.js" type="text/javascript"></script>
<script src="/javascripts/prototype.js" type="text/javascript"></script>
<script type="text/javascript">
// 提交查询表单
 function sm(){
  var form=document.getElementById("search");
   new Ajax.Updater(
      "report_lists",
      form.action,
      {
        method: "post",
        asynchronous: true,
        evalScripts: true,
        parameters: Form.serialize(form) + '&authenticity_token=' + window._token
      }
    );
  }
  
  function sm_folder(){
  var form=document.getElementById("search_folder");
   new Ajax.Updater(
      "folders",
      form.action,
      {
        method: "post",
        asynchronous: true,
        evalScripts: true,
        parameters: Form.serialize(form) + '&authenticity_token=' + window._token
      }
    );

  }
 // 根据时间 获取测试记录的 异步请求
 function show_all(){
     show_div(0);
        ClearCookie("pageDiv_status");
        SetCookie("pageDiv_status","all");
   }
   
  function last_three_day(){
   ClearCookie("pageDiv_status");
   SetCookie("pageDiv_status","st");
    var pars='timer=st';
    new Ajax.Updater(
    'report_lists',
    "/user/reports/get_reports_by_time",
    {
    method: 'get',
    parameters: pars
    });
 }
  function last_week(){
   ClearCookie("pageDiv_status");
   SetCookie("pageDiv_status","yz");
  var pars='timer=yz';
   new Ajax.Updater(
    'report_lists',
    "/user/reports/get_reports_by_time",
    {
    method: 'get',
    parameters: pars
    });
 }
  function last_month(){
   ClearCookie("pageDiv_status");
   SetCookie("pageDiv_status","yy");
  var pars='timer=yy';
   new Ajax.Updater(
    'report_lists',
    "/user/reports/get_reports_by_time",
    {
    method: 'get',
    parameters: pars
    });
 }
 function get_new_reports(){
   ClearCookie("pageDiv_status");
   SetCookie("pageDiv_status","new");
   new Ajax.Updater(
    'report_lists',
    "/user/reports/get_new_reports",
    {
    method: 'get'
    });
 }

function get_import_reports(){
   ClearCookie("pageDiv_status");
   SetCookie("pageDiv_status","imp");
   new Ajax.Updater(
    'report_lists',
    "/user/reports/get_import_reports",
    {
    method: 'get'
    });
 }
 function show_by_folder(id){
    $("report_lists").innerHTML="";
     new Ajax.Updater(
      'report_lists',
      "/user/reports/get_reports_by_folder/"+id,
      {
      method: 'get'
      });
 }
  function new_folder(){
   //alert(11);
  $("new_folder_name").show();
  }
  
  // 创建文件夹
  function create_new_folder(){
   var foldername = $("new_folder_name_input").value;
   //alert(foldername);
  if(foldername.length==0){
  alert("文件名不能为空");
   }else{  
    var pars='name='+foldername;
    new Ajax.Updater(
      'folders',
      "/user/reports/create_folder",
      {
      method: 'get',
      parameters: pars
      });
     show_div(1);
    }
 }
 
 function show_div(num){
   if (num==0){
   $("report_lists").show();
   $("folders").hide();
   $("search_survey").show();
   $("search_folder_div").hide();
   ClearCookie("divname");
   SetCookie("divname","report_lists");
   }
   if (num==1){
    $("report_lists").hide();
    $("report_lists").innerHTML="";
    $("folders").show();
   $("search_survey").hide();
   $("search_folder_div").show();
     ClearCookie("divname");
     SetCookie("divname","folders");
     //alert("set");
     hidden_img();
   }
 }
 

function delsome(){
       var checked_arrays=[];
       var sta=GetCookie("pageDiv_status");
       var boxes=document.getElementsByClassName("check_boxes");
       for(i=0; i<boxes.length; i++) {
          if (boxes[i].checked){  
             checked_arrays[i]=boxes[i].value;
           }  
       }
       if (checked_arrays.length >0){
          var shanchu=window.confirm("删除之后将不可恢复，你确定要删除么?");
          if(shanchu==true){
            var pars="arr="+checked_arrays+"&status="+sta;
            new Ajax.Updater(
            'report_lists',
            "/user/reports/delete_records",
            {
            method: 'get',
            parameters: pars
            });
          }
        }else{
        alert("请选择一个操作对象");
        }
}
function delall(){
       var checked_arrays=[];
       var sta=GetCookie("pageDiv_status");
       var boxes=document.getElementsByClassName("check_boxes");
       for(i=0; i<boxes.length; i++) {
             checked_arrays[i]=boxes[i].value;
       }
        var shanchuall=window.confirm("全部删除之后将不可恢复，你确定要全部删除么?");
         if(shanchuall==true){
            var pars="arr="+checked_arrays+"&status="+sta;
            new Ajax.Updater(
            'report_lists',
            "/user/reports/delete_records",
            {
            method: 'get',
            parameters: pars
            });
        }
}
  //标记为重要 报告
function markItems(){
    var checked_arrays=[];
    var sta=GetCookie("pageDiv_status");
    var boxes=document.getElementsByClassName("check_boxes");
    for(i=0; i<boxes.length; i++) {
       if (boxes[i].checked){  
          checked_arrays[i]=boxes[i].value;
        }  
     }
     
      if (checked_arrays.length >0){
         var pars="arr="+checked_arrays+"&status="+sta;
         new Ajax.Updater(
          'report_lists',
          "/user/reports/imp_marks",
          {
          method: 'get',
          parameters: pars
          });
       }else{
        alert("请选择一个操作对象");
      }
}
 function removemarkItems(){
    var checked_arrays=[];
    var sta=GetCookie("pageDiv_status");
    var boxes=document.getElementsByClassName("check_boxes");
    for(i=0; i<boxes.length; i++) {
       if (boxes[i].checked){  
          checked_arrays[i]=boxes[i].value;
        }  
     }
     
     if (checked_arrays.length >0){
         var pars="arr="+checked_arrays+"&status="+sta;
         new Ajax.Updater(
          'report_lists',
          "/user/reports/remove_marks",
          {
          method: 'get',
          parameters: pars
          });
      }else{
        alert("请选择一个操作对象");
      }
  }
function move(){
$("transfer_folder").show();
}
// 当select 变化时 提交异步请求 
function select_change(){
  var target=$('transfer_folder').value;
  var sta=GetCookie("pageDiv_status");
  if(target=="不移动"){
    // do nothing!
    }else{
      var checked_arrays=[];
      var boxes=document.getElementsByClassName("check_boxes");
       //alert(boxes.length);
      for(i=0; i<boxes.length; i++) {
         if (boxes[i].checked){  
             checked_arrays[i]=boxes[i].value;
             }  
       }// for 循环结束
        if (checked_arrays.length==0){ // 确定移动？
        alert("请至少选择一项！");
        }else{
         var yes=window.confirm("你确定要移动么");
          if (yes==true){
             var pars="arr="+checked_arrays+'&f_id='+$('transfer_folder').value+"&status="+sta;;
              new Ajax.Updater(
              'report_lists',
              "/user/reports/change_folder",
              {
              method: 'get',
              parameters: pars
              });
          } // 确定移动
    }
    
    }//判断是否要移动结束
}
   function show_all_folder(){
     get_folder_page(1)
   }
// 不用了。。
      function hidden_select(){
      $("transfer_folder").hide();
      }
      // 刷新页面时 根据cokies 记录 
 function show_which_div(){
    var page=<%=@has_pages  || false%>; // 判断是不是 分页结果
    var divname=GetCookie("divname");
    var show_status=GetCookie("pageDiv_status");
    if(page==true){// 如果分页直接显示结果 
       if(divname=="report_lists"){
        show_div(0);
        }else if(divname=="folders"){
        show_div(1);
        }
    }else{  // 如果不是 分页根据记忆状态显示相应的结果
      if(divname=="report_lists"){
          var report_lists_div= $("report_lists");
          if(show_status=="st"){
            report_lists_div.innerHTML="";
            last_three_day();
          }else if(show_status=="yz"){
            report_lists_div.innerHTML="";
            last_week();
          }else if(show_status=="yy"){
            report_lists_div.innerHTML="";
            last_month();
          }else if(show_status=="new"){
           report_lists_div.innerHTML="";
            get_new_reports();
          }else if(show_status=="imp"){
          report_lists_div.innerHTML="";
            get_import_reports();
          } 
        show_div(0);
        }else if(divname=="folders"){
        show_div(1);
       }
      }
      
      show_oldPage_status(divname,show_status);
  }

  
  function show_oldPage_status(divname,status){
  img_id="imgFor_showAll"
   if(divname!=null && divname=="folders")
    {
      hidden_img(imgFor_showFolder);
    }else if(divname!=null && divname=="report_lists"){
        if(status=="st"){
          img_id="imgFor_showThree";
        }else if(status=="yz"){
          img_id="imgFor_showWeek";
        }else if(status=="yy"){
          img_id="imgFor_showMonth";
        }else if(status=="new"){
          img_id="imgFor_showNew";
        }else if(status=="imp"){
          img_id="imgFor_showImport";
        }     
         hidden_img(img_id);
    }
  }
  
  // js 设置 cookies 
  function SetCookie(name,value,expires,path,domain,secure)
    {
      var expDays = expires*24*60*60*1000;
      var expDate = new Date();
      expDate.setTime(expDate.getTime()+expDays);
      var expString = ((expires==null) ? "" : (";expires="+expDate.toGMTString()))
      var pathString = ((path==null) ? "" : (";path="+path))
      var domainString = ((domain==null) ? "" : (";domain="+domain))
      var secureString = ((secure==true) ? ";secure" : "" )
      document.cookie = name + "=" + escape(value) + expString + pathString + domainString + secureString;
    }  

      // js  获取 cookies
    function GetCookie(name)
    {
      var result = null;
      var myCookie = document.cookie + ";";
      var searchName = name + "=";
      var startOfCookie = myCookie.indexOf(searchName);
      var endOfCookie;
      if (startOfCookie != -1)
    {
      startOfCookie += searchName.length;
      endOfCookie = myCookie.indexOf(";",startOfCookie);
      result = unescape(myCookie.substring(startOfCookie, endOfCookie));
    }
     return result;
    } 
    
    // js 删除 cookies 
    function ClearCookie(name)
    {
      var OneDays=1*24*60*60*1000;
      var expDate = new Date();
      expDate.setTime(expDate.getTime()-OneDays);
      document.cookie=name+"=;expires="+expDate.toGMTString();
    } 

  function notice_showbg(){
          if($("operate_result_notice").innerHTML != ""){
            $("notice").show();
          }
          window.setTimeout(hide, 4000);
        }
        function hide() {
          $("notice").hide();
        }
        
  function hidden_img(img_id){
     $("imgFor_showAll").hide();
     $("imgFor_showThree").hide();
     $("imgFor_showWeek").hide();
     $("imgFor_showMonth").hide();
     $("imgFor_showNew").hide();
     $("imgFor_showImport").hide();
     $("imgFor_showFolder").hide();
       if (img_id != null){
         $(img_id).show();
       }
    }
  </script>
  
</head>
<body onload="show_which_div();">
<div id="page">
	<div id="header">
		<ol>
		<li><img src="/images/user/report_list/baogaoguanli.jpg" width="124" height="40" /></li>
		</ol>
		<ul>
        <li id="org-text"><%=current_user.name%></li>
		    <li><a href="/login/logout">安全退出</a></li>
		</ul>
	</div>
    <div id="content">
    <div class="left">
        	<div class="left01">
        	<div id="search_survey">
            	<form id="search" name="search" action="/user/reports/search" method="post">
    	    <%= tag(:input, :type => "hidden", :name => request_forgery_protection_token.to_s, 
                 :value => form_authenticity_token) %> 
              <input type="hidden" name="page_num" id="page_num" value="1">
              <input type="hidden" name="user_id" id="user_id"value="<%=session[CURRENT_USER_ID]%>" />
               <ul>
                <li style="margin-top:10px;">关键字：</li>
                <li class="bc"><input type="text" id="text" name="keyword"  value="<%=flash[:keyword]%>" /></li>
                </ul>
                <ul>
                <li  style="margin-top:10px;">起始日期：</li>
                <li class="bc">
                <%= text_field 'date', 'date1', :onClick=>"SelectDate(this,'yyyy-MM-dd')" , :id=>"text",:size=>10,:value=>flash[:date1]%></li>
                </ul>
                <ul>
                <li  style="margin-top:10px;">终止日期：</li>
                <li class="bc">
                <%= text_field 'date', 'date2', :onClick=>"SelectDate(this,'yyyy-MM-dd')" , :id=>"text" ,:size=>10,:value=>flash[:date2]%></li>
                </ul><br />
                <p><a href="#"   onclick="sm()";><img src="/images/user/report_list/anniu_07.jpg" width="76" height="22" /></a></p>
                </form>
            </div>
            
            
            <div id="search_folder_div" style="display:none;">
            <form id="search_folder" name="search_folder" action="/user/reports/search_folder" method="post">
    	    <%= tag(:input, :type => "hidden", :name => request_forgery_protection_token.to_s, 
                 :value => form_authenticity_token) %> 
              <input type="hidden" name="fpage_num" id="folder_page_num" value="1">
              <input type="hidden" name="user_id" id="user_id"value="<%=session[CURRENT_USER_ID]%>" />
               <ul>
                <li style="margin-top:10px;">关键字：</li>
                <li class="bc"><input type="text" id="text" name="keyword"  value="<%=flash[:keyword]%>" /></li>
                </ul>
                <ul>
                <li  style="margin-top:10px;">起始日期：</li>
                <li class="bc">
                <%= text_field 'date', 'date1', :onClick=>"SelectDate(this,'yyyy-MM-dd')" , :id=>"text",:size=>10,:value=>flash[:date1]%></li>
                </ul>
                <ul>
                <li  style="margin-top:10px;">终止日期：</li>
                <li class="bc">
                <%= text_field 'date', 'date2', :onClick=>"SelectDate(this,'yyyy-MM-dd')" , :id=>"text" ,:size=>10,:value=>flash[:date2]%></li>
                </ul><br />
                <p>
                <a href="#"   onclick="sm_folder()";><img src="/images/user/report_list/anniu_07.jpg" width="76" height="22" /></a>
                </p>
                </form>            
            </div>
           
           </div> <!--div .left01 结束-->
            <div class="left02">
            <ol>
                <li><img src="/images/user/report_list/005.jpg" width="14" height="12" />　
                    </li>
                <li><img src="/images/user/report_list/001.jpg" width="14" height="14" />　
                     </li>
                <li><img src="/images/user/report_list/002.jpg" width="14" height="14" />
                     </li>
                <li><img src="/images/user/report_list/003.jpg" width="14" height="14" />
                     </li>
                </ol>
            	<ul>
                <li><a href="/user/reports/index"  onclick="show_all(); hidden_img(imgFor_showAll); ">全部报告</a></li>
                <li><a href="#" onclick="last_three_day(); show_div(0);hidden_img(imgFor_showThree); ">最近三天</a></li>
                <li id="last_week"><a href="#" onclick="last_week();show_div(0);hidden_img(imgFor_showWeek); ">最近一周</a></li>
                <li><a href="#"  onclick="last_month();   show_div(0); hidden_img(imgFor_showMonth);">最近一月</a></li>
                </ul><!-- -->
                <ul class="tubiao">
                    <li class="tt">
                    <img  id="imgFor_showAll" src="/images/user/report_list/to_right.gif" 
                      width="16" height="22"   style="margin-top:3px;"/></li>
                    <li class="tt">
                    <img src="/images/user/report_list/to_right.gif"  id="imgFor_showThree" style="display:none;"
                      width="16" height="22"   style="margin-top:3px;"/></li>
                    <li class="tt" >
                    <img src="/images/user/report_list/to_right.gif"  id="imgFor_showWeek" style="display:none;"
                      width="16" height="22"   style="margin-top:3px;"/></li>
                    <li class="tt">
                    <img src="/images/user/report_list/to_right.gif" id="imgFor_showMonth"  style="display:none;"
                      width="16" height="22"   style="margin-top:3px;"/></li>
                </ul>
            </div>
            <div class="left03">
            <ol>
                <li><img src="/images/user/report_list/sad.jpg" width="14" height="12" /></li>
                <li><img src="/images/user/report_list/sde.jpg" width="14" height="14" /></li>
                </ol>
            	<ul>
                <li><a href="#" onclick="get_new_reports();  show_div(0); hidden_img(imgFor_showNew);">未读报告</a></li>
                <li> <a href="#" onclick="get_import_reports();   show_div(0); hidden_img(imgFor_showImport);"><font color="#ff0000">
                  重要报告</font></a></li>
                </ul>
                <ul class="tubiao2">
                    <li class="tt2">
                    <img  id="imgFor_showNew" src="/images/user/report_list/to_right.gif"  style="display:none;"
                      width="16" height="22"   style="margin-top:3px;"/></li>
                    <li class="tt2">
                    <img src="/images/user/report_list/to_right.gif"  id="imgFor_showImport"  style="display:none;"
                      width="16" height="22"   style="margin-top:3px;"/></li>
                </ul>
            </div>
            <div class="left05">
            <ol>
                <li><img style="margin-left:40px:" src="/images/user/report_list/myfolder.jpg" width="15" height="14" /></li>
           </ol>
           <ul>
             <li><a href="javascript:;" onclick="show_div(1); show_all_folder(); hidden_img(imgFor_showFolder);">我的文件夹</a></li>
           </ul>
            <ul class="tubiao3">
                    <li class="tt3">
                    <img  id="imgFor_showFolder" src="/images/user/report_list/to_right.gif"  style="display:none;margin-top:4px;"
                      width="16" height="22"   style="margin-top:3px;"/></li>
            </ul>
            </div>
        </div>
    <div class="right">
        <div id="folders" style="display:none">
         <%= render :partial => "folders", :object => @folders %>
        </div>
        <div id="report_lists" style="margin:0px 2px 0 2px;">
         <%= render :partial => "report_list", :object => @test_records %>
        </div>   
     </div>
     
      </div>
        <div class="back">
          <a href="/user/test/home"><img src="/images/back.png" width="88" height="27" /></a>
        </div>
    </div>

  <div id="footer">
<h1>北京心嘉源咨询有限公司 CopyRight © www.iyaoi.cn 2009</h1>
</div>

<script type="text/javascript">
<!--
  function show_folder_selector() {
    var selector = $('folder-selector');
    var height = selector.getHeight();
    selector.show();
  }

  
  // 
  function move_to_folder(){
    //var target=$('transfer_folder').value;
    var sta=GetCookie("pageDiv_status");

    //if(target=="不移动"){
    //}
    //else{
        var checked_arrays=[];
        var boxes=document.getElementsByClassName("check_boxes");
        for(i=0; i<boxes.length; i++) {
           if (boxes[i].checked){
               checked_arrays[i]=boxes[i].value;
           }
        }
        if (checked_arrays.length==0){
            alert("请至少选择一项！");
        }else{
            var pars="arr="+checked_arrays + "&status="+sta + "&";
            new Ajax.Updater(
            'report_lists',
            "/user/reports/change_folder",
            {
              method: 'get',
              parameters: pars + $('move-to-form').serialize()
            });
        }

    //}
  }
//-->
</script>
</body>
</html>
